package learning.spring.helloworldspring;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;

public class HelloApp {
    public static void main(String[] args) {
//        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
//        MessageRenderer messageRenderer = context.getBean("renderer", MessageRenderer.class);
//        messageRenderer.render();

        GenericXmlApplicationContext genericXmlApplicationContext = new GenericXmlApplicationContext();
        genericXmlApplicationContext.load("classpath:app-context-annotations.xml");
        genericXmlApplicationContext.refresh();

        MessageProvider messageProvider = genericXmlApplicationContext.getBean("provider", MessageProvider.class);
        System.out.println(messageProvider.getMessage());

        MessageRenderer messageRenderer = genericXmlApplicationContext.getBean("renderer", MessageRenderer.class);
        messageRenderer.render();
    }
}
